<template>
  <!-- 河道设备查看 -->
  <div v-loading="loading" element-loading-text="拼命加载中">
    <el-row>
      <!-- 搜索框 -->
      <el-col :span="24">
        <div class="search-wrapper">
          <ul class="search-box">
            <li><span class="filter-name">设备类别：</span>
              <el-select v-model="listQuery.equipType" placeholder="请选择" clearable style="width:130px"
                         class="filter-item">
                <el-option v-for="item in equipTypeOptions" :key="item.dictId" :label="item.dictName"
                           :value="item.dictValue"/>
              </el-select>
            </li>
            <li><span class="filter-name">所属河段：</span>
              <el-select v-model="listQuery.riverName" placeholder="请选择" clearable style="width:150px" class="filter-item">
                <el-option label="长江" value="1"></el-option>
                <el-option label="黄河" value="2"></el-option>
                <el-option label="钱塘江" value="3"></el-option>
              </el-select>
            </li>
            <li style="padding-left:10px;"><el-button style="vertical-align:middle;margin-top:-2px;" round size="mini" type="primary" @click="getList">查询</el-button></li>
          </ul>
        </div>
      </el-col>
    </el-row>
    <!-- 表格 -->
    <el-row>
      <el-col :span="24">
        <div class="data-wrapper">
          <template v-if="tableData3!=null">
            <el-table ref="multipleTable" :data="tableData3"  tooltip-effect="dark" style="width: 100%">
              <el-table-column type="index" width="50" label="序号" :index="indexMethod">
              </el-table-column>
              <el-table-column prop="equipCode" label="设备编码" width="120">
              </el-table-column>
              <el-table-column prop="equipName" label="设备名称" width="180">
              </el-table-column>
              <el-table-column prop="equipType.name" label="设备类型" width="180">
              </el-table-column>
              <el-table-column prop="riverFlow" label="所属街镇" width="200">
              </el-table-column>
              <el-table-column prop="riverName" label="所属河段" width="200">
              </el-table-column>
              <el-table-column label="经纬度" width="180" >
                <template slot-scope="scope">
                  <span>{{ scope.row.longitude}}/{{ scope.row.latitude}}</span>
                </template>
              </el-table-column>
              <el-table-column prop="partsName" label="关联部件" width="180">
              </el-table-column>
              <el-table-column prop="partsCode" label="关联部件编码" width="180" >
              </el-table-column>
              <el-table-column label="GIS地图">
              </el-table-column>
            </el-table>
          </template>
        </div>
      </el-col>
    </el-row>
    <!-- 底部按钮和分页 -->
    <el-row :gutter="20" v-if="dataCount" type="flex" justify="space-between" align="center" class="page-wrapper">
      <el-col :span="24">
        <div class="page-item">
          <el-pagination background
                         @size-change="handleSizeChange"
                         @current-change="handleCurrentChange"
                         :current-page.sync="listQuery.currentPage"
                         :page-sizes="pageSizes"
                         :page-size="listQuery.pageSize"
                         layout="total, sizes, prev, pager, next, jumper"
                         :total="dataCount"/>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
    export default {
        data(){
            return {
                equipTypeOptions:[],
                options: [{
                    value: "1修改",
                    label: "1233修改"
                }],
                tableData3:null,
                loading:false,
                //默认数据总数
                dataCount:0,
                pageSizes:[5, 10, 20, 30, 40],
                //查询条件
                listQuery: {
                    currentPage:1,
                    pageSize:5
                }
            }
        },
        created() {
            this.getList();
            this.getEquipTypeOptions();
        },
        methods:{
            getList() {
                this.loading=true;
                this.postRequest('/api/rcs/equips/getEquipList',this.listQuery).then((res)=>{
                    this.tableData3=res.data.data
                    this.dataCount=res.data.count;
                    this.loading = false
                })
                    .catch((error)=>{
                        //错误信息
                        this.$message.error(error)
                    })
            },
            //获取设备类型字典值
            getEquipTypeOptions(){
                this.getDictionary({types:["EQUIP_TYPE"]}).then(res => {
                    var data = res.data;
                    if(data.status == 200){
                        this.equipTypeOptions = data.data["EQUIP_TYPE"];
                    }else{
                        this.$message.error(data.msg);
                    }
                })
                    .catch((error)=>{
                        this.$message.error(error)
                    })
            },
            indexMethod(index) {
                return (index+1)+(this.listQuery.currentPage-1)*this.listQuery.pageSize;
            },
            handleSizeChange(size) {
                this.listQuery.pageSize=size;
                this.listQuery.currentPage=1;
                this.getList()
            },
            handleCurrentChange(currentPage) {
                this.listQuery.currentPage=currentPage;
                this.getList()
            }
        },
        mounted(){},
        updated(){},
        destroyed(){},
    }
</script>
<style scoped>

</style>